﻿using SolidWorks.Interop.sldworks;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MechAddin.Common
{
    internal static class ThisAssemblyDoc
    {

        public static void FixComponents(this AssemblyDoc swDoc2,params Component2[] comps)
        {
            if (swDoc2==null){return;}
            if (comps==null) {return; }
            if (comps.Length == 0) {return; }
            comps[0].Select4(false, null, false);
            for (int i = 1; i < comps.Length; i++)
            {
                comps[i].Select4(true, null, false);
            }
            swDoc2.FixComponent();

        }

        public static void ReplaceComponents(this AssemblyDoc swDoc2, string newComponentPath, List<Component2> comps)
        {
            if (swDoc2 == null) { return; } if (comps == null) { return; } if (comps.Count== 0) { return; }
            if (!File.Exists(newComponentPath)){return;}
            string ex = Path.GetExtension(newComponentPath).ToUpper();
            if (ex == ".SLDPRT"||ex==".SLDASM")
            {
                if (comps.Select())
                {
                    swDoc2.ReplaceComponents2(newComponentPath,string.Empty,false,0,true);
                }  
            }


        }

    }
}
